<?php

/**
 * @author ducnhat
 * @email ddnhat@gmail.com
 * @copyright 2014
 */

class Admin_Form_ValidateUserLogin{
	
	protected $_messageError = null;
    protected $_arrData = null;
    
    public function __construct($params = array()){
        
        $validateUsername = new Zend_Validate();
        $validatePassword = new Zend_Validate();
        
        $option = array('table' => 'users', 'field' => 'username');
        
        $validateUsername->addValidator(new Zend_Validate_NotEmpty(), true)
                      ->addValidator(new Zend_Validate_StringLength(6, 32), true)
                      ->addValidator(new Zend_Validate_Regex('#^[a-zA-Z0-9\-_\.\s]+$#'), true)
                      ->addValidator(new Zend_Validate_Db_NoRecordExists($option), true);
        
        $validatePassword->addValidator(new Zend_Validate_NotEmpty(), true)
                      ->addValidator(new Zend_Validate_StringLength(6, 32), true)
                      ->addValidator(new Zend_Validate_Regex('#^[a-zA-Z0-9\-_\.\s]+$#'), true);
    }
    
    public function isError(){
    	if(count($this->_messageError) > 0){
    	   return true;
    	}
        
        return false;
    }
    
    public function getMessageError(){
        return $this->_messageError;
    }
    
    public function getData(){
        return $this->_arrData;
    }
}